package com.yituo.mjworld.mvc.form;

import com.alibaba.fastjson.JSONObject;
import com.yituo.mjworld.core.annotation.Rules;

import java.util.HashMap;
import java.util.Map;

/**
 * 查询表单的扩展类
 */
public class QueryGoods extends QueryForm {

  /**
   * 展示优先级
   */
  public static final int BY_ORDER_NUM = 0;

  /**
   * 综合.
   */
  public static final int BY_ALL = 1;
  /**
   * 销量
   */
  public static final int BY_SALE_NUM = 2;
  /**
   * 上架时间/上新
   */
  public static final int BY_CREATEDATE = 3;
  /**
   * 价格
   */
  public static final int BY_PRICE = 4;

  @Rules(fieldName = "搜索类型", min = "0", max = "4")
  public int type;
  @Rules(fieldName = "排序类型", required = false)
  public boolean asc;
  @Rules(fieldName = "二级分类ID", min = "0")
  public int childId;

  /**
   * 测试方法!
   *
   * @param args
   */
  public static void main(String[] args) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("type", new Object[]{1});
//    params.put("asc", new Object[]{true});
    QueryGoods goods = new QueryGoods();
    System.out.println(goods.init(goods, params));
    System.out.println(goods.validate());
    System.out.println(JSONObject.toJSONString(goods));
  }

  public int getChildId() {
    return childId;
  }

  public void setChildId(int childId) {
    this.childId = childId;
  }

  public int getType() {
    return type;
  }

  public void setType(int type) {
    this.type = type;
  }

  public boolean isAsc() {
    return asc;
  }

  public void setAsc(boolean asc) {
    this.asc = asc;
  }
}
